(function($,window,undefined){
	/**外面全局的多语言资源类 **/
	var rss=window.rss; 
	
	/**外面的基础要的页面传来的参数**/
	var localInfo=window.localInfo;
	 
	
	// TODO 要写的代码
	var userInfo = {
		oldAccountType: "",
		oldUserAccount: "",
		oldAuthCode: "",
		newAccountType: "",
		newUserAccount: "",
		newAuthCode: ""
	};
	
	//用户账户信息
	var userAcctInfoData = {};
	
	//登录帐号
	var loginAccount = localInfo.userAccount;
	
	var reqClientType = localInfo.reqClientType;
	
	//安全账户
	var security_email_account = "";
	var security_email_account_state = 0;
	var security_phone_account = "";
	var security_phone_account_state = 0;
	
	//当前选择国家码
	var currentCountryCode = 0;
	
	//
	var authCodeLabel = '<div class="dbtn2 sbtn r" act="getVerificationCode" intervaltime="60"><span>' + rss.getAuthCode + '</span><p id="get_authcode_error_info"></p></div>';
	
	//帐号类型
	var EMAIL_ACCOUNT_TYPE = 1;
	var PHONE_ACCOUNT_TYPE = 2;
	var SECURITY_EMAIL_TYPE = 5;
	var SECURITY_PHONE_TYPE = 6;
	
	//获取账号信息范围
	var ACCOUNT_INFO_CHOOSE_LIST = 1;
	var ACCOUNT_INFO_NO_REPEAT = 2;
	var ACCOUNT_INFO_ALL = 3;
	
	//page token
	var PAGE_TOKEN = localInfo.pageToken;
	
	updateUI();
	registerValidator();
	initString();
	
	/* 修改密码  */
	$("#cpsw").Dialog({
		title: rss.changePwd,
		btnRight: {
			text: rss.ok,
			fn: function() {
				var self = this;
				if (!ec.form.validator($("#oldPassword"), true)
					|| !ec.form.validator($("#newPassword"), true)
					|| !ec.form.validator($("#confirmPassword"), true)) {
					return false;
				}
				var oldPassword = $("#oldPassword").val();
				var newPassword = $("#newPassword").val();
				updateUserPwdByOld(oldPassword, newPassword, function() {
					self.hide();
					showTipDialog(rss.changePwdSuccess, rss.close_btn, rss.changePwdSuccess, function() {
						gotoUrl(rss.logoutUrl);
					});
				});
			}
		},
		btnLeft: {
			text: rss.cancel_btn,
			fn: function() {}
		},
		beforeAction: function() {
			ec.form.input.label.defaults.ifRight="10px";
		    ec.form.input.label($("#oldPassword"),rss.oldPwd);
		    ec.form.input.label($("#newPassword"),rss.newPwd);
		    ec.form.input.label($("#confirmPassword"),rss.confirmPwd);
			validatorPassword.call(this);
		},
		html: '<div class="dinput"><input id="oldPassword" type="password"></div><p id="old_pwd_error_info"></p>' +
			'<div class="dinput"><input id="newPassword" type="password"></div><p id="new_pwd_error_info"></p>' +
			'<p style="margin-top:25px;">' +rss.pwdInputTip+ '</p>' +
			'<div class="dinput"><input id="confirmPassword" type="password"></div><p id="confirm_pwd_error_info"></p>'
	});
	
	
	//设置安全邮箱
	$("#security_email_set_btn").Dialog({
		title: rss.authentication,
		btnRight: {
			text: rss.nextStep,
			fn: function() {
				var self = this;
				
				if (!ec.form.validator($("#security_account_verify_code"), true)) {
					return;
				}
				
				userInfo.oldAuthCode = $("#security_account_verify_code").val();
				chkAuthCode(userInfo.oldAccountType, 3, userInfo.oldUserAccount, userInfo.oldAuthCode, function() {
					self.$dialog.find('[role=confirm]').Dialog({
						title: rss.secEmailAddr,
						btnRight: {
							text: rss.set,
							fn: function() {
								var email = $("#security_email_set_input").val();
								var authCode = $("#security_account_verify_code").val();
								var self = this;
								
								if (!ec.form.validator($("#security_email_set_input"), true)
									|| !ec.form.validator($("#security_account_verify_code"), true)) {
									return;
								}
								self.disabled();
								setPhoneEmail(2, 5, email, authCode, function() {
									self.hide();
									showTipDialog(rss.setSuccess, rss.close_btn, rss.secEmailAddrSetTip,function() {
										window.location.reload();
									});
									updateUI();
								});
							}
						},
						btnLeft: {
							text: rss.cancel_btn,
							fn: function() {}
						},
						actions: {
							getVerificationCode: function() {
								var email = $("#security_email_set_input").val();
								var self = this;
								
								if (!ec.form.validator($("#security_email_set_input"), true)) {
									return;
								}
								
								if (checkAuthCodeBtnState(this.$dialog)) {
									getAuthCode(1, email, 0, function(ret) {
										if (ret) {
											authCodeCountDown(self.$dialog, rss.resend);
										}
									});
								}
							}
						},
						beforeAction: function() {
							validatorAuthCode.call(this, "#security_email_set_input");
							validatorEmail.call(this, "#security_email_set_input", "#security_account_verify_code");
						},
						html: '<p class="ucEmailAddrAuthTip">' +rss.secEmailAddrAuthTip+ '</p>' +
							'<div class="dinput"><input id="security_email_set_input" type="text" placeholder="' +rss.inputNewSecEmail+ '"></div><p id="email_error_info"></p>' +
							authCodeLabel +
							'<div class="dinput sinput"><input id="security_account_verify_code" type="text" placeholder="' +rss.emailAuthCode+ '"></div><p id="auth_code_error_info"></p>' +
							'<div class="relative"><div class="pop hidden">' +
							' <b class="uptick"></b>' +
							' <p class="poptips">' +rss.errorInfo+ '</p>' +
							'</div></div>'
					}).Dialog("show");
					self.hide();
				});
			}
		},
		btnLeft: {
			text: rss.cancel_btn,
			fn: function() {}
		},
		actions: {
			getVerificationCode: function() {
				var self = this;
				if (checkAuthCodeBtnState(this.$dialog)) {
					getAuthCode(userInfo.oldAccountType, userInfo.oldUserAccount, 3, function(ret) {
						if (ret) {
							authCodeCountDown(self.$dialog, rss.resend);
						}
					});
				}
			}
		},
		beforeAction: function() {
			validatorAuthCode.call(this);
			initDropList($("#security_email_set_droplist"),$("#security_account_verify_code"));
			adjustPlaceHolder($("#security_email_set_droplist span").text(),$("#security_account_verify_code"));
		},
		html: '<p class="inptips2">' +rss.secEmailAddrNeedAuth+ '</p>' +
			'<div id="security_email_set_droplist"></div>' +
			authCodeLabel +
			'<input id="security_email_verify_input" type="hidden">' +
			'<div class="dinput" style="width:50%;"><input id="security_account_verify_code" type="text" placeholder="' +rss.inputAuthCodeTip+ '"></div><p id="auth_code_error_info"></p>'
	});
	
	//验证安全邮箱
//	$("#security_email_auth_btn").Dialog({
//		title: rss.authentication,
//		btnRight: {
//			text: rss.nextStep,
//			fn: function() {
//				var self = this;
//				
//				if (!ec.form.validator($("#security_account_verify_code"), true)) {
//					return;
//				}
//				
//				userInfo.oldAuthCode = $("#security_account_verify_code").val();
//				chkAuthCode(userInfo.oldAccountType, 3, userInfo.oldUserAccount, userInfo.oldAuthCode, function() {
//					self.$dialog.find('[role=confirm]').Dialog({
//						title: rss.secEmailAddr,
//						btnRight: {
//							text: rss.set,
//							fn: function() {
//								var email = $("#security_email_auth_input").val();
//								var authCode = $("#security_account_verify_code").val();
//								var self = this;
//								
//								if (!ec.form.validator($("#security_email_auth_input"), true)
//									|| !ec.form.validator($("#security_account_verify_code"), true)) {
//									return;
//								}
//								self.disabled();
//								setPhoneEmail(2, 5, email, authCode, function() {
//									self.hide();
//									showTipDialog(rss.setSuccess, rss.close_btn, rss.secEmailAddrSetTip);
//									updateUI();
//								});
//							}
//						},
//						btnLeft: {
//							text: rss.cancel_btn,
//							fn: function() {}
//						},
//						actions: {
//							getVerificationCode: function() {
//								var email = $("#security_email_auth_input").val();
//								var self = this;
//								
//								if (!ec.form.validator($("#security_email_auth_input"), true)) {
//									return;
//								}
//								
//								if (checkAuthCodeBtnState(this.$dialog)) {
//									getAuthCode(1, email, 0, function(ret) {
//										if (ret) {
//											authCodeCountDown(self.$dialog, rss.resend);
//										}
//									});
//								}
//							}
//						},
//						beforeAction: function() {
//							validatorAuthCode.call(this, "#security_email_auth_input");
//							validatorEmail.call(this, "#security_email_auth_input", "#security_account_verify_code");
//						},
//						html: '<p class="ucEmailAddrAuthTip">' +rss.secEmailAddrAuthTip+ '</p>' +
//							'<div class="dinput"><input id="security_email_auth_input" type="text" placeholder="' +rss.inputNewSecEmail+ '"></div><p id="email_error_info"></p>' +
//							authCodeLabel +
//							'<div class="dinput sinput"><input id="security_account_verify_code" type="text" placeholder="' +rss.emailAuthCode+ '"></div><p id="auth_code_error_info"></p>' +
//							'<div class="relative"><div class="pop hidden">' +
//							' <b class="uptick"></b>' +
//							' <p class="poptips">' +rss.errorInfo+ '</p>' +
//							'</div></div>'
//					}).Dialog("show");
//					self.hide();
//				});
//			}
//		},
//		btnLeft: {
//			text: rss.cancel_btn,
//			fn: function() {}
//		},
//		actions: {
//			getVerificationCode: function() {
//				var self = this;
//				if (checkAuthCodeBtnState(this.$dialog)) {
//					getAuthCode(userInfo.oldAccountType, userInfo.oldUserAccount, 3, function(ret) {
//						if (ret) {
//							authCodeCountDown(self.$dialog, rss.resend);
//						}
//					});
//				}
//			}
//		},
//		beforeAction: function() {
//			validatorAuthCode.call(this);
//			initDropList($("#security_email_set_droplist"),$("#security_account_verify_code"));
//			adjustPlaceHolder($("#security_email_set_droplist span").text(),$("#security_account_verify_code"));
//		},
//		html: '<p class="inptips2">' +rss.secEmailAddrNeedAuth+ '</p>' +
//			'<div id="security_email_set_droplist"></div>' +
//			authCodeLabel +
//			'<input id="security_email_verify_input" type="hidden">' +
//			'<div class="dinput" style="width:50%;"><input id="security_account_verify_code" type="text" placeholder="' +rss.inputAuthCodeTip+ '"></div><p id="auth_code_error_info"></p>'
//	});
	
	//修改安全邮箱
	$("#security_email_modify_btn").Dialog({
		title: rss.authentication,
		btnRight: {
			text: rss.nextStep,
			fn: function() {
				var self = this;
				if (!ec.form.validator($("#security_account_verify_code"), true)) {
					return;
				}
				userInfo.oldAuthCode = $("#security_account_verify_code").val();
				chkAuthCode(userInfo.oldAccountType, 3, userInfo.oldUserAccount, userInfo.oldAuthCode, function() {
					self.$dialog.find('[role=confirm]').Dialog({
						title: rss.newEmailAddrTitle,
						btnRight: {
							text: rss.change,
							fn: function() {
								var self = this;
								var email = $("#security_email_modify_input").val();
								var authCode = $("#security_account_verify_code").val();
								
								if (!ec.form.validator($("#security_email_modify_input"), true)
									|| !ec.form.validator($("#security_account_verify_code"), true)) {
									return;
								}
								self.disabled();
								setPhoneEmail(3, 5, email, authCode, function() {
									self.hide();
									showTipDialog(rss.updataSuccess, rss.close_btn, rss.secEmailAddrSetTip,function() {
										window.location.reload();
									});
									updateUI();
								});
							}
						},
						btnLeft: {
							text: rss.cancel_btn,
							fn: function() {}
						},
						actions: {
							getVerificationCode: function() {
								var email = $("#security_email_modify_input").val();
								var self = this;
								
								if (!ec.form.validator($("#security_email_modify_input"), true)) {
									return;
								}
								
								if (checkAuthCodeBtnState(this.$dialog)) {
									getAuthCode(1, email, 0, function(ret) {
										if (ret) {
											authCodeCountDown(self.$dialog, rss.resend);
										}
									});
								}
							}
						},
						beforeAction: function() {
							validatorAuthCode.call(this, "#security_email_modify_input");
							validatorEmail.call(this, "#security_email_modify_input", "#security_account_verify_code");
						},
						html: '<p class="ucEmailAddrAuthTip">' +rss.secEmailAddrAuthTip+ '</p>' +
							'<div class="dinput"><input id="security_email_modify_input" type="text" placeholder="' +rss.inputNewSecEmail+ '"></div><p id="email_error_info"></p>' +
							authCodeLabel +
							'<div class="dinput sinput"><input id="security_account_verify_code" type="text" placeholder="' +rss.emailAuthCode+ '"><p id="auth_code_error_info"></p></div>' +
							'<div class="relative"><div class="pop hidden">' +
							' <b class="uptick"></b>' +
							' <p class="poptips">' +rss.errorInfo+ '</p>' +
							'</div></div>'
					}).Dialog("show");
					self.hide();
				});
			}
		},
		btnLeft: {
			text: rss.cancel_btn,
			fn: function() {}
		},
		actions: {
			getVerificationCode: function() {
				var self = this;
				if (checkAuthCodeBtnState(this.$dialog)) {
					getAuthCode(userInfo.oldAccountType, userInfo.oldUserAccount, 3, function(ret) {
						if (ret) {
							authCodeCountDown(self.$dialog, rss.resend);
						}
					});
				}
			}
		},
		beforeAction: function() {
			validatorAuthCode.call(this);
			initDropList($("#security_email_set_droplist"),$("#security_account_verify_code"));
			adjustPlaceHolder($("#security_email_set_droplist span").text(),$("#security_account_verify_code"));
		},
		html: '<p class="inptips2">' +rss.secEmailAddrChaneAuth+ '</p>' +
			'<div id="security_email_set_droplist"></div>' +
			authCodeLabel +
			'<input id="security_email_verify_input" type="hidden">' +
			'<div class="dinput" style="width:50%;"><input id="security_account_verify_code" type="text" placeholder="' +rss.inputAuthCodeTip+ '"></div><p id="auth_code_error_info"></p>'
	});
	
	//删除安全邮箱
	$("#security_email_remove_btn").Dialog({
		title: rss.authentication,
		btnRight: {
			text: rss.remove,
			fn: function() {
				var self = this;
				if (!ec.form.validator($("#security_account_verify_code"), true)) {
					return;
				}
				userInfo.oldAuthCode = $("#security_account_verify_code").val();
				delPhoneEmail(security_email_account, 5, function(data) {
					self.hide();
					updateUI();
					window.location.reload();
				});
			}
		},
		btnLeft: {
			text: rss.cancel_btn,
			fn: function() {}
		},
		actions: {
			getVerificationCode: function() {
				var self = this;
				if (checkAuthCodeBtnState(this.$dialog)) {
					getAuthCode(userInfo.oldAccountType, userInfo.oldUserAccount, 3, function(ret) {
						if (ret) {
							authCodeCountDown(self.$dialog, rss.resend);
						}
					});
				}
			}
		},
		beforeAction: function() {
			validatorAuthCode.call(this);
			initDropList($("#security_email_set_droplist"),$("#security_account_verify_code"));
			adjustPlaceHolder($("#security_email_set_droplist span").text(),$("#security_account_verify_code"));
		},
		html: '<p class="inptips2">' +rss.secEmailAddrRemoveTip+ '</p>' +
			'<div id="security_email_set_droplist"></div>' +
			authCodeLabel +
			'<input id="security_email_verify_input" type="hidden">' +
			'<div class="dinput" style="width:50%;"><input id="security_account_verify_code" type="text" placeholder="' +rss.inputAuthCodeTip+ '"></div><p id="auth_code_error_info"></p>'
	});
	
	//设置安全手机号码
	$("#security_phone_set_btn").Dialog({
		title: rss.authentication,
		btnRight: {
			text: rss.nextStep,
			fn: function() {
				var self = this;
				if (!ec.form.validator($("#security_account_verify_code"), true)) {
					return;
				}
				userInfo.oldAuthCode = $("#security_account_verify_code").val();
				chkAuthCode(userInfo.oldAccountType, 3, userInfo.oldUserAccount, userInfo.oldAuthCode, function() {
					self.$dialog.find('[role=confirm]').Dialog({
						title: rss.secPhone,
						btnRight: {
							text: rss.set,
							fn: function() {
								var countryCode = $("#security_phone_set_country_code input").val();
								var phone = $("#security_phone_set_input").val();
								var authCode = $("#security_account_verify_code").val();
								var self = this;
								
								if (!ec.form.validator($("#security_phone_set_input"), true)
									|| !ec.form.validator($("#security_account_verify_code"), true)) {
									return;
								}
								self.disabled();
								setPhoneEmail(2, 6, countryCode + phone, authCode, function() {
									self.hide();
									showTipDialog(rss.setSuccess, rss.close_btn, rss.secPhoneUseTip,function() {
										window.location.reload();
									});
									updateUI();
								});
							}
						},
						btnLeft: {
							text: rss.cancel_btn,
							fn: function() {}
						},
						actions: {
							getVerificationCode: function() {
								var countryCode = $("#security_phone_set_country_code input").val();
								var phone = $("#security_phone_set_input").val();
								var self = this;
								
								if (!ec.form.validator($("#security_phone_set_input"), true)) {
									return;
								}
								
								if (checkAuthCodeBtnState(this.$dialog)) {
									getAuthCode(2, countryCode + phone, 3, function(ret) {
										if (ret) {
											authCodeCountDown(self.$dialog, rss.resend);
										}
									});
								}
							}
						},
						beforeAction: function() {
							validatorAuthCode.call(this, "#security_phone_set_input");
							validatorPhoneNumber.call(this, "#security_phone_set_input", "#security_account_verify_code");
							initCountryCodesDropList($("#security_phone_set_country_code"), "#security_phone_set_input");
						},
						html: '<p class="ucEmailAddrAuthTip">' +rss.secPhoneAuthRuleTip+ '</p>' +
							'<div id="security_phone_set_country_code"></div>' +
							'<div class="dinput"><input id="security_phone_set_input" type="text" placeholder="' +rss.inputNewPhoneNumber+ '"></div><p id="phone_error_info"></p>' +
							authCodeLabel +
							'<div class="dinput sinput"><input id="security_account_verify_code" type="text" placeholder="' +rss.smsAuthCode+ '"></div><p id="auth_code_error_info"></p>' +
							'<div class="relative"><div class="pop hidden">' +
							' <b class="uptick"></b>' +
							' <p class="poptips">' +rss.errorInfo+ '</p>' +
							'</div></div>'
					}).Dialog("show");
					
					self.hide();
				});
			}
		},
		btnLeft: {
			text: rss.cancel_btn,
			fn: function() {}
		},
		actions: {
			getVerificationCode: function() {
				var self = this;
				if (checkAuthCodeBtnState(this.$dialog)) {
					getAuthCode(userInfo.oldAccountType, userInfo.oldUserAccount, 3, function(ret) {
						if (ret) {
							authCodeCountDown(self.$dialog, rss.resend);
						}
					});
				}
			}
		},
		beforeAction: function() {
			validatorAuthCode.call(this);
			initDropList($("#security_email_set_droplist"),$("#security_account_verify_code"));
			registerValidator();
			adjustPlaceHolder($("#security_email_set_droplist span").text(),$("#security_account_verify_code"));
		},
		html: '<p class="inptips2">' +rss.secPhoneAuthTip+ '</p>' +
			'<div id="security_email_set_droplist"></div>' +
			authCodeLabel +
			'<input id="security_email_verify_input" type="hidden">' +
			'<div class="dinput" style="width:50%;"><input id="security_account_verify_code" type="text" placeholder="' +rss.inputAuthCodeTip+ '"></div><p id="auth_code_error_info"></p>'
	});
	

	//验证安全手机号
//	$("#security_phone_auth_btn").Dialog({
//		title: rss.authentication,
//		btnRight: {
//			text: rss.nextStep,
//			fn: function() {
//				var self = this;
//				if (!ec.form.validator($("#security_account_verify_code"), true)) {
//					return;
//				}
//				userInfo.oldAuthCode = $("#security_account_verify_code").val();
//				chkAuthCode(userInfo.oldAccountType, 3, userInfo.oldUserAccount, userInfo.oldAuthCode, function() {
//					self.$dialog.find('[role=confirm]').Dialog({
//						title: rss.secPhone,
//						btnRight: {
//							text: rss.set,
//							fn: function() {
//								var countryCode = $("#security_phone_set_country_code input").val();
//								var phone = $("#security_phone_auth_input").val();
//								var authCode = $("#security_account_verify_code").val();
//								var self = this;
//								
//								if (!ec.form.validator($("#security_phone_auth_input"), true)
//									|| !ec.form.validator($("#security_account_verify_code"), true)) {
//									return;
//								}
//								self.disabled();
//								setPhoneEmail(2, 6, countryCode + phone, authCode, function() {
//									self.hide();
//									showTipDialog(rss.setSuccess, rss.close_btn, rss.secPhoneUseTip);
//									updateUI();
//								});
//							}
//						},
//						btnLeft: {
//							text: rss.cancel_btn,
//							fn: function() {}
//						},
//						actions: {
//							getVerificationCode: function() {
//								var countryCode = $("#security_phone_set_country_code input").val();
//								var phone = $("#security_phone_auth_input").val();
//								var self = this;
//								
//								if (!ec.form.validator($("#security_phone_auth_input"), true)) {
//									return;
//								}
//								
//								if (checkAuthCodeBtnState(this.$dialog)) {
//									getAuthCode(2, countryCode + phone, 3, function(ret) {
//										if (ret) {
//											authCodeCountDown(self.$dialog, rss.resend);
//										}
//									});
//								}
//							}
//						},
//						beforeAction: function() {
//							validatorAuthCode.call(this, "#security_phone_auth_input");
//							validatorPhoneNumber.call(this, "#security_phone_auth_input", "#security_account_verify_code");
//							initCountryCodesDropList($("#security_phone_set_country_code"), "#security_phone_auth_input");
//						},
//						html: '<p class="ucEmailAddrAuthTip">' +rss.secPhoneAuthRuleTip+ '</p>' +
//							'<div id="security_phone_set_country_code"></div>' +
//							'<div class="dinput"><input id="security_phone_auth_input" type="text" placeholder="' +rss.inputNewPhoneNumber+ '"></div><p id="phone_error_info"></p>' +
//							authCodeLabel +
//							'<div class="dinput sinput"><input id="security_account_verify_code" type="text" placeholder="' +rss.smsAuthCode+ '"></div><p id="auth_code_error_info"></p>' +
//							'<div class="relative"><div class="pop hidden">' +
//							' <b class="uptick"></b>' +
//							' <p class="poptips">' +rss.errorInfo+ '</p>' +
//							'</div></div>'
//					}).Dialog("show");
//					
//					self.hide();
//				});
//			}
//		},
//		btnLeft: {
//			text: rss.cancel_btn,
//			fn: function() {}
//		},
//		actions: {
//			getVerificationCode: function() {
//				var self = this;
//				if (checkAuthCodeBtnState(this.$dialog)) {
//					getAuthCode(userInfo.oldAccountType, userInfo.oldUserAccount, 3, function(ret) {
//						if (ret) {
//							authCodeCountDown(self.$dialog, rss.resend);
//						}
//					});
//				}
//			}
//		},
//		beforeAction: function() {
//			validatorAuthCode.call(this);
//			initDropList($("#security_email_set_droplist"),$("#security_account_verify_code"));
//			adjustPlaceHolder($("#security_email_set_droplist span").text(),$("#security_account_verify_code"));
//		},
//		html: '<p class="inptips2">' +rss.secPhoneAuthTip+ '</p>' +
//			'<div id="security_email_set_droplist"></div>' +
//			authCodeLabel +
//			'<input id="security_email_verify_input" type="hidden">' +
//			'<div class="dinput" style="width:50%;"><input id="security_account_verify_code" type="text" placeholder="' +rss.inputAuthCodeTip+ '"></div><p id="auth_code_error_info"></p>'
//	});
	
	//修改安全手机号
	$("#security_phone_modify_btn").Dialog({
		title: rss.authentication,
		btnRight: {
			text: rss.nextStep,
			fn: function() {
				var self = this;
				if (!ec.form.validator($("#security_account_verify_code"), true)) {
					return;
				}
				userInfo.oldAuthCode = $("#security_account_verify_code").val();
				chkAuthCode(userInfo.oldAccountType, 3, userInfo.oldUserAccount, userInfo.oldAuthCode, function() {
					self.$dialog.find('[role=confirm]').Dialog({
						title: rss.newSecPhone,
						btnRight: {
							text: rss.change,
							fn: function() {
								var self = this;
								var countryCode = $("#security_phone_set_country_code input").val();
								var phone = $("#security_phone_modify_input").val();
								var authCode = $("#security_account_verify_code").val();
								
								if (!ec.form.validator($("#security_phone_modify_input"), true)
									|| !ec.form.validator($("#security_account_verify_code"), true)) {
									return;
								}
								self.disabled();
								setPhoneEmail(3, 6, countryCode + phone, authCode, function() {
									self.hide();
									showTipDialog(rss.updataSuccess, rss.close_btn, rss.secPhoneUseTip,function() {
										window.location.reload();
									});
									updateUI();
								});
							}
						},
						btnLeft: {
							text: rss.cancel_btn,
							fn: function() {}
						},
						actions: {
							getVerificationCode: function() {
								var countryCode = $("#security_phone_set_country_code input").val();
								var phone = $("#security_phone_modify_input").val();
								var self = this;
								
								if (!ec.form.validator($("#security_phone_modify_input"), true)) {
									return;
								}
								
								if (checkAuthCodeBtnState(this.$dialog)) {
									getAuthCode(2, countryCode + phone, 3, function(ret) {
										if (ret) {
											authCodeCountDown(self.$dialog, rss.resend);
										}
									});
								}
							}
						},
						beforeAction: function() {
							validatorAuthCode.call(this, "#security_phone_modify_input");
							validatorPhoneNumber.call(this, "#security_phone_modify_input", "#security_account_verify_code");
							initCountryCodesDropList($("#security_phone_set_country_code"), "#security_phone_modify_input");
							registerValidator();
						},
						html: '<p class="ucEmailAddrAuthTip">' +rss.secPhoneAuthRuleTip+ '</p>' +
							'<div id="security_phone_set_country_code"></div>' +
							'<div class="dinput"><input id="security_phone_modify_input" type="text" placeholder="' +rss.inputPhoneNumber+ '"></div><p id="phone_error_info"></p>' +
							authCodeLabel +
							'<div class="dinput sinput"><input id="security_account_verify_code" type="text" placeholder="' +rss.smsAuthCode+ '"><p id="auth_code_error_info"></p></div>' +
							'<div class="relative"><div class="pop hidden">' +
							' <b class="uptick"></b>' +
							' <p class="poptips">' +rss.errorInfo+ '</p>' +
							'</div></div>'
					}).Dialog("show");
					self.hide();
				});
			}
		},
		btnLeft: {
			text: rss.cancel_btn,
			fn: function() {}
		},
		actions: {
			getVerificationCode: function() {
				var self = this;
				if (checkAuthCodeBtnState(this.$dialog)) {
					getAuthCode(userInfo.oldAccountType, userInfo.oldUserAccount, 3, function(ret) {
						if (ret) {
							authCodeCountDown(self.$dialog, rss.resend);
						}
					});
				}
			}
		},
		beforeAction: function() {
			validatorAuthCode.call(this);
			initDropList($("#security_email_set_droplist"),$("#security_account_verify_code"));
			adjustPlaceHolder($("#security_email_set_droplist span").text(),$("#security_account_verify_code"));
		},
		html: '<p class="inptips2">' +rss.secPhoneAuthNeedTip+ '</p>' +
			'<div id="security_email_set_droplist"></div>' +
			authCodeLabel +
			'<input id="security_email_verify_input" type="hidden">' +
			'<div class="dinput" style="width:50%;"><input id="security_account_verify_code" type="text" placeholder="' +rss.inputAuthCodeTip+ '"></div><p id="auth_code_error_info"></p>'
	});
	
	function adjustPlaceHolder(accountStr,authCodeEle)
	{
		if(accountStr.indexOf("@")>=0)
		{
			authCodeEle.attr("placeholder",rss.emailAuthCode);
		}
		else
		{
			authCodeEle.attr("placeholder",rss.smsAuthCode);
		}
	}
	
	
	//删除安全手机号
	$("#security_phone_remove_btn").Dialog({
		title: rss.authentication,
		btnRight: {
			text: rss.remove,
			fn: function() {
				var self = this;
				if (!ec.form.validator($("#security_account_verify_code"), true)) {
					return;
				}
				userInfo.oldAuthCode = $("#security_account_verify_code").val();
				delPhoneEmail(security_phone_account, 6, function(data) {
					self.hide();
					updateUI();
					window.location.reload();
				});
			}
		},
		btnLeft: {
			text: rss.cancel_btn,
			fn: function() {}
		},
		actions: {
			getVerificationCode: function() {
				var self = this;
				if (checkAuthCodeBtnState(this.$dialog)) {
					getAuthCode(userInfo.oldAccountType, userInfo.oldUserAccount, 3, function(ret) {
						if (ret) {
							authCodeCountDown(self.$dialog, rss.resend);
						}
					});
				}
			}
		},
		beforeAction: function() {
			validatorAuthCode.call(this);
			initDropList($("#security_email_set_droplist"),$("#security_account_verify_code"));
			adjustPlaceHolder($("#security_email_set_droplist span").text(),$("#security_account_verify_code"));
		},
		html: '<p class="inptips2">' +rss.secPhoneRemoveTip+ '</p>' +
			'<div id="security_email_set_droplist"></div>' +
			authCodeLabel +
			'<input id="security_email_verify_input" type="hidden">' +
			'<div class="dinput" style="width:50%;"><input id="security_account_verify_code" type="text" placeholder="' +rss.inputAuthCodeTip+ '"></div><p id="auth_code_error_info"></p>'
	});
	
	function showTipDialog(title, btnText, content, callback) {
		$("<div>").Dialog({
			title: title,
			btnRight: {
				text: btnText,
				fn: function() {
					this.hide();
					if (typeof callback == "function") {
						callback();
					}
				}
			},
			btnLeft: false,
			html: '<div class="center">' +
				'<img class="dimg" src="'+localInfo.successImgPath+'">' +
				'<p class="inptips2">' + content + '</p>' +
				'</div>'
		}).Dialog("show");
	}
	
	/* 保存帐号信息 */
	function initUserInfo(data) {
		userAcctInfoData = data;
		if(data.userAcctInfoList != null && data.userAcctInfoList.length!=0) {
			userInfo.oldAccountType = data.userAcctInfoList[0].accountType;
			userInfo.oldUserAccount = data.userAcctInfoList[0].userAccount;
		}
	}
	
	/* 使用旧密码更新密吗 */
	function updateUserPwdByOld(oldPassword, newPassword, callback) {
 		var params = {
 			oldPassword: oldPassword,
 			newPassword: newPassword,
 			reqClientType: reqClientType,
			pageToken: PAGE_TOKEN
 		};
 		ajaxHandler("updateUserPwdByOld", params, function(data) {
 			if (data && data.isSuccess == 1) {
 				callback();
 			} else {
 				var errorCode = data.errorCode;
 				switch (errorCode) {
 					case "70001201": {
 						showError($(".errortip"), rss.error_70001201);
 						break;
 					}
 					case "70001401": {
 						showError($(".errortip"), rss.error_70001401);
 						break;
 					}
 					case "70008001": {
 						showError($(".errortip"), rss.error_70008001);
 						break;
 					}
 					case "70002070": {
 						showError($(".errortip"), rss.error_70002070);
 						break;
 					}
 					case "70002020": {
 						showError($(".errortip"), rss.error_70002020);
 						break;
 					}
 					case "70002003": {
 						showError($(".errortip"), rss.error_70002003_1);
 						break;
 					}
 					case "70002016": {
 						showError($(".errortip"), rss.error_70002016_2);
 						break;
 					}
 					case "70002057": {
 						showError($(".errortip"), rss.error_70002057_2);
 						break;
 					}
 					case "70002058": {
 						showError($(".errortip"), rss.error_70002058_1);
 						break;
 					}
 					default: {
 						showError($(".errortip"), rss.updatePwdError);
 						break;
 					}
 				}
 			}
 		}, function(){}, true, "json");
 	}
	
	/* 获取验证码 */
	function getAuthCode(accountType, account, type, callback) {
		var params = {};
		var method = "";
		var infoElement = $("#get_authcode_error_info");
		if (accountType == 1 || accountType == 5) {
			method = "getEMailAuthCode";
			params = {
	 			email: account,
	 			emailReqType: type,
	 			accountType: accountType,
	 			reqClientType: reqClientType,
 				pageToken: PAGE_TOKEN,
 				languageCode:localInfo.lang
	 		};
		} else if (accountType == 2 || accountType == 6) {
			method = "getSMSAuthCode";
			params = {
 				accountType: accountType,
 				userAccount: account,
 				reqClientType: reqClientType,
 				mobilePhone: account,
 				smsReqType:type,
 				pageToken: PAGE_TOKEN,
 				languageCode:localInfo.lang
 			};
		}
		
 		ajaxHandler(method, params, function(data) {
 			if (data && data.isSuccess == 1) {
 				if (method == "getSMSAuthCode") {
 					showSuccess(infoElement, rss.phoneMegHasSendTo.format(getExpressPhone(account)));
 				} else if (method == "getEMailAuthCode") {
 					showSuccess(infoElement, rss.emialHasSendTo.format(account));
 					$(".userAccount").html(account);
 				}
 			} else {
 				switch(data.errorCode) {
	 				case "10000001":
	 				case "10000002":
	 				case "10000003":
	 				case "70001201": {
	 					showError(infoElement, rss.error_10000001);
	 					break;
	 				}
	 				case "70001401": {
	 					showError(infoElement, rss.error_70001401);
	 					break;
	 				}
	 				case "70002002": {
	 					showError(infoElement, rss.error_needcountrycode);
	 					break;
	 				}
	 				case "70002001": {
	 					showError(infoElement, rss.error_70002001);
	 					break;
	 				}
	 				case "70002028": {
	 					showError(infoElement, rss.error_70002028);
	 					break;
	 				}
	 				case "70002046": {
	 					showError(infoElement, rss.error_70002046);
	 					break;
	 				}
	 				case "70002030": {
	 					showError(infoElement, rss.error_70002030);
	 					break;
	 				}
	 				case "70001102": {
	 					if (method == "getEMailAuthCode") {
	 						showError(infoElement, rss.error_70001102_0);
	 					} else if (method == "getSMSAuthCode") {
	 						showError(infoElement, rss.error_70001102_1);
	 					}
	 					break;
	 				}
	 				case "70001104": {
	 					if (method == "getEMailAuthCode") {
	 						showError(infoElement, rss.error_70001104_0, "left");
	 					} else if (method == "getSMSAuthCode") {
	 						showError(infoElement, rss.error_70001104_1, "left");
	 					}
	 					break;
	 				}
	 				case "10000004": {
	 					showError(infoElement, rss.error_10000004);
	 					break;
	 				}
	 				case "10000002": {
	 					showError(infoElement, rss.error_10000002);
	 					break;
	 				}
	 				default: {
	 					showError(infoElement, rss.get_authcode_error);
	 					break;
	 				}
 				}
 			}
 			
 			if (callback) {
				callback(data.isSuccess == 1 ? true : false);
			}
 		}, function(){}, true, "json");
 	}
	
	/* 设置安全邮箱或者安全手机 */
	function setPhoneEmail(opType, newAccountType, newUserAccount, newAuthCode, callback) {
		var params = {
			opType: opType,
			oldAccountType: userInfo.oldAccountType,
			oldUserAccount: userInfo.oldUserAccount,
			oldAuthCode: userInfo.oldAuthCode,
			newAccountType: newAccountType,
			newUserAccount: newUserAccount,
			newAuthCode: newAuthCode,
 			reqClientType: reqClientType,
			pageToken: PAGE_TOKEN
 		};
 		ajaxHandler("setPhoneEmail", params, function(data) {
 			if (data && data.isSuccess == 1) {
 				if (typeof callback == "function") {
 					callback();
 				}
 			} else {
 				if (data.errorCode == "10000001" || data.errorCode == "70001201") {
 					showError($(".errortip"), rss.error_10000001);
 				} else if (data.errorCode == "70006007") {
 					if (newAccountType == 1 || newAccountType == 5) {
 	 					showError($(".errortip"), rss.error_70006007_0);
 					} else {
 						showError($(".errortip"), rss.error_70006007_1);
 					}
 				} else if (data.errorCode == "70001401") {
 					showError($(".errortip"), rss.error_70001401);
 				} else if (data.errorCode == "70002001") {
 					showError($(".errortip"), rss.error_70002001);
 				} else if (data.errorCode == "70002055") {
 					showError($(".errortip"), rss.error_70002055);
 				} else if (data.errorCode == "70006006") {
 					showError($(".errortip"), rss.error_70006006);
 				} else if (data.errorCode == "70002002") {
 					showError($(".errortip"), rss.error_70002002);
 				} else if (data.errorCode == "70002003") {
 					showError($(".errortip"), rss.error_70002003);
 				} else if (data.errorCode == "70002057") {
 					showError($(".errortip"), rss.error_70002057_0);
 				} else if (data.errorCode == "70002058") {
 					showError($(".errortip"), rss.error_70002058);
 				} else if (data.errorCode == "70002039") {
 					showError($(".errortip"), rss.error_70002039);
 				}
 			}
 		}, function(){}, true, "json");
	}
	
	/* 解绑安全邮箱或者安全手机 */
	function delPhoneEmail(delAccount, type, callback) {
		var params = {
			oldAccountType: userInfo.oldAccountType,
			oldUserAccount: userInfo.oldUserAccount,
			oldAuthCode: userInfo.oldAuthCode,
			delAccountType: type,
			delUserAccount: delAccount,
			reqClientType: reqClientType,
			pageToken: PAGE_TOKEN
		};
		ajaxHandler("delPhoneEmail", params, function(data) {
 			if (data && data.isSuccess == 1) {
 				callback();
 			} else {
 				switch(data.errorCode) {
	 				case "10000001": {
	 					showError($(".errortip"), rss.error_10000001);
	 					break;
	 				}
 					case "10000002": {
 						showError($(".errortip"), rss.error_10000002);
	 					break;
 					}
 					case "10000004": {
 						showError($(".errortip"), rss.error_10000004);
	 					break;
 					}
 					case "70001201": {
 						showError($(".errortip"), rss.error_10000001);
	 					break;
 					}
 					case "70001401": {
 						showError($(".errortip"), rss.error_70001401);
	 					break;
 					}
 					case "70002001": {
 						showError($(".errortip"), rss.error_70002001);
	 					break;
 					}
 					case "70002073": {
 						showError($(".errortip"), rss.error_70002073);
	 					break;
 					}
 					case "70002043": {
 						showError($(".errortip"), rss.error_70002043);
	 					break;
 					}
 					case "70002039": {
 						showError($(".errortip"), rss.error_70002039);
	 					break;
 					}
 					case "70002053": {
 						showError($(".errortip"), rss.error_70002053);
	 					break;
 					}
 					case "70002057": {
 						showError($(".errortip"), rss.error_70002057_1);
	 					break;
 					}
 					case "70002058": {
 						showError($(".errortip"), rss.error_70002058);
	 					break;
 					}
 					case "70006006": {
 						showError($(".errortip"), rss.error_70006006);
	 					break;
 					}
 					case "70002003": {
 						showError($(".errortip"), rss.error_70002003);
	 					break;
 					}
 					case "70002016": {
 						showError($(".errortip"), rss.error_70002016);
	 					break;
 					}
 					default: {
 						showError($(".errortip"), rss.error_70002016);
	 					break;
 					}
 				}
 			}
 		}, function(){}, true, "json");
	}
	
	/* 检查验证码 */
	function chkAuthCode(accountType, authOprType, userAccount, authCode, callback) {
		var params = {
			accountType: accountType,
			userAccount: userAccount,
			authCode: authCode,
			authOprType: authOprType,
 			reqClientType: reqClientType,
			pageToken: PAGE_TOKEN
 		};
 		ajaxHandler("chkAuthCode", params, function(data) {
 			if (data && data.isSuccess == 1) {
 				callback();
 			} else {
 				var errorCode = data.errorCode;
 				if (errorCode == "70002039") {
					showError($(".errortip"), rss.error_70002039);
				}
 				else if (errorCode ==  "70002057") {
					showError($(".errortip"), rss.error_70002057_1);
				}
				else if (errorCode ==  "70002058") {
					showError($(".errortip"), rss.error_70002058);
				}
				else {
					showError($(".errortip"), rss.authCodeError);
				}
 			}
 		}, function(){}, true, "json");
	}
	
	/* 获取用户帐号信息 */
	function getUserAccInfo(userAccount, allAccount, callback) {
		var params = {
			userAccount: userAccount,
			reqClientType: reqClientType,
			isGetAll: allAccount,
			pageToken: PAGE_TOKEN,
			accountType:localInfo.accountType
		};
		ajaxHandler("getUserAccInfo", params, function(data) {
 			if (data && data.isSuccess == 1) {
 				callback(data);
 			} else {
 				security_email_account = "";
 				security_phone_account = "";
 				security_email_account_state = 0;
 				security_phone_account_state = 0;
 				updateSecPhoneUI();
 				updateSecEmailUI();
 			}
 		}, function(){}, true, "json");
	}
	
	function initCountryCodesDropList(jqEle, validateEle) {
		var items = [];
		var contrysArr = localInfo.countryCodes.split(",");
		$.each(contrysArr, function(n, value) {
			var temp = value.split("(");
			var key = temp[0];
			key = key.replace("+", "00");
//			items[key] = value;
			if (value) {
				items.push({value:key, label:value});
			}
		});
		
		currentCountryCode = "0086";
		
		jqEle.DropList({
			items: items,
			defaultValue:localInfo.default_country_code,
			onChange: function(key, value) {
				currentCountryCode = key;
				
				if (validateEle && $(validateEle).val()) {
					ec.form.validator($(validateEle), true);
				}
			}
		});
	}
	
	/* 生成 Drop List */
	function initDropList(jqEle,authCodeEle) {
		var items = [];
		if (userAcctInfoData && userAcctInfoData.userAcctInfoList) {
			for (var i = 0; i < userAcctInfoData.userAcctInfoList.length; i++) {
				if (userAcctInfoData.userAcctInfoList[i].accountState == 1 || userAcctInfoData.userAcctInfoList[i].accountState == 0) {
//					items[i] = userAcctInfoData.userAcctInfoList[i].userAccount;
					items.push({
						value: JSON.stringify({
							index:i,
							account:userAcctInfoData.userAcctInfoList[i].userAccount
						}),
						label: getExpressPhone(userAcctInfoData.userAcctInfoList[i].userAccount)
					});
				}
			}
		}
		
		userInfo.oldAccountType = userAcctInfoData.userAcctInfoList[0].accountType;
		userInfo.oldUserAccount = userAcctInfoData.userAcctInfoList[0].userAccount;
		
		jqEle.DropList({
			items: items,
			onChange: function(key, value) {
				userInfo.oldAccountType = userAcctInfoData.userAcctInfoList[key.index].accountType;
				userInfo.oldUserAccount = userAcctInfoData.userAcctInfoList[key.index].userAccount;
				
				adjustPlaceHolder(userInfo.oldUserAccount,authCodeEle);
			}
		});
	}
	
	function checkSecurityAccount(accounts) {
		security_email_account = "";
		security_phone_account = "";
		security_email_account_state = 0;
		security_phone_account_state = 0;
		
		for (var i = 0; i < accounts.length; i++) {
			if (accounts[i].accountType == SECURITY_EMAIL_TYPE) {
				security_email_account = accounts[i].userAccount;
				security_email_account_state = accounts[i].accountState;
			}
			
			if (accounts[i].accountType == SECURITY_PHONE_TYPE) {
				security_phone_account = accounts[i].userAccount;
				security_phone_account_state = accounts[i].accountState;
			}
		}
	}
	
	function updateUI() {
		getUserAccInfo(loginAccount, ACCOUNT_INFO_NO_REPEAT, function(data) {
			initUserInfo(data);
		});
		getUserAccInfo(loginAccount, ACCOUNT_INFO_ALL, function(data) {
			if (data.userAcctInfoList) {
				checkSecurityAccount(data.userAcctInfoList);
				updateSecPhoneUI();
				updateSecEmailUI();
			}
		});
	}
	
	function updateSecEmailUI() {
		if (security_email_account) {
			if (security_email_account_state == 1) {
				$("#security_email_text").text(security_email_account + " (" +rss.verified+ ")");
			} else {
				$("#security_email_text").text(security_email_account + " (" +rss.unverified+ ")");
				$("#security_email_auth_btn").removeClass("hidden");
			}
			$("#security_email_set_btn").addClass("hidden");
			$("#security_email_remove_btn").removeClass("hidden");
			$("#security_email_modify_btn").removeClass("hidden");
		} else {
			$("#security_email_text").text("(" +rss.notSet+ ")");
			
			// 存在已激活账号,才显示绑定安全手机按钮
			if (localInfo.existActiveAccount != "0")
			{
				$("#security_email_set_btn").removeClass("hidden");
			}
			
			$("#security_email_remove_btn").addClass("hidden");
			$("#security_email_modify_btn").addClass("hidden");
		}
	}
	
	function updateSecPhoneUI() {
		if (security_phone_account) {
			if (security_phone_account_state == 1) {
				$("#security_phone_text").text(getExpressPhone(security_phone_account));
				$("#security_phone_tip").text(" (" +rss.verified+ ")");
			} else {
				$("#security_phone_text").text(getExpressPhone(security_phone_account));
				$("#security_phone_tip").text(" (" +rss.unverified+ ")");
				$("#security_phone_auth_btn").removeClass("hidden");
			}
			$("#security_phone_set_btn").addClass("hidden");
			$("#security_phone_remove_btn").removeClass("hidden");
			$("#security_phone_modify_btn").removeClass("hidden");
		} else {
			$("#security_phone_text").text("(" +rss.notSet+ ")");
			
			// 存在已激活账号,才显示绑定安全手机按钮
			if (localInfo.existActiveAccount != "0")
			{
				$("#security_phone_set_btn").removeClass("hidden");
			}
			
			$("#security_phone_remove_btn").addClass("hidden");
			$("#security_phone_modify_btn").addClass("hidden");
		}
	}
	
	function checkAuthCodeBtnState(ele, text) {
		var authEle = ele.find("[act='getVerificationCode']");
		var disabled = authEle.attr("disabled");
		if (disabled) {
			return false;
		}
		
		return true;
	}
	
	function authCodeCountDown(ele, text) {
		var authEle = ele.find("[act='getVerificationCode']");
		authEle.addClass("auth_code_grey");
		jsInnerTimeout(authEle, text);
	}
	
	function resetAuthCodeMenu(ele) {
		var authEle = ele.find("[act='getVerificationCode']");
		authEle.attr("intervaltime", 0);
	}
	
	function validatorPassword() {
 		var oldPassword = $("#oldPassword"),
		newPassword = $("#newPassword"),
		confirmPassword = $("#confirmPassword"),
		self = this;
 		
 		this.disabled();
	
		//validate old password
		ec.form.validator.bind(oldPassword, {
			type : [ "require"/*, "length","pwdComplax"*/ ],
			trim : false,
			validOnChange : true,
			min : 8,
			max : 32,
			msg_ct : "#old_pwd_error_info",
			msg : {
				require : rss.common_js_inputpwd
//				length : rss.error_10000001_2
			}
		});
		
		//validate new password
		ec.form.validator.bind(newPassword, {
			type : [ "require", "length", "password", "pwdEqual" ],
			trim : false,
			validOnChange : true,
			compareTo : confirmPassword,
			min : 8,
			max : 32,
			msg_ct : "#new_pwd_error_info",
			msg : {
				require : rss.common_js_inputpwd,
				length : rss.common_js_pwdlimit,
				password:rss.modifyUserPwd_input_8_32_complax_chars_desc,
				pwdEqual : rss.common_js_pwdnotsame
			}
		});
		
		//validate confirm password
		ec.form.validator.bind(confirmPassword, {
			type : [ "require", "pwdEqual" ],
			trim : false,
			validOnChange : true,
			compareTo : newPassword,
			msg_ct : "#confirm_pwd_error_info",
			msg : {
				require : rss.common_js_confirmpwd,
				pwdEqual : rss.common_js_pwdnotsame
			}
		});
		
		oldPassword.on("blur", function() {
			//validatorPassword.call(this);
		}).on("keyup", function(e) {
			updateBtnState();
		});
		newPassword.on("blur", function() {
			//validatorPassword.call(this);
		}).on("keyup", function(e) {
			updateBtnState();
		});
		confirmPassword.on("blur", function() {
			//validatorPassword.call(this);
		}).on("keyup", function(e) {
			updateBtnState();
		});
		
		function validatorPassword() {
			$("#old_pwd_error_info").empty();
			$("#new_pwd_error_info").empty();
			$("#confirm_pwd_error_info").empty();
			
			ec.form.validator($(this), true);
			updateBtnState();
		}

		function updateBtnState() {
			if (oldPassword.val() && newPassword.val() && confirmPassword.val()) {
				self.enable();
			} else {
				self.disabled();
			}
		}
 	}
	
	function validatorEmail(ele, dependency) {
		var self = this;
		var emailEle = $(ele);
		ec.form.validator.bind(emailEle, {
			type: ["require", "email"],
			trim: false,
			validOnChange: true,
			msg_ct: "#email_error_info",
			msg: {
				require: rss.validatorEmailRequire,
				email: rss.validatorEmail

			}
		});
		
		emailEle.on("keyup", function() {
			if (dependency) {
				if ($(this).val() && $(dependency).val()) {
					self.enable();
				} else {
					self.disabled();
				}
			}
		});
	}
	
	function validatorPhoneNumber(ele, dependency) {
		var phoneEle = $(ele);
		var self = this;
		
		ec.form.validator.bind(phoneEle, {
			type: ["require", "phoneNumber"],
			trim: false,
			validOnChange: true,
			msg_ct: "#phone_error_info",
			msg: {
				require: rss.validatorPhoneRequire,
				phoneNumber: rss.validatorPhone
			}
		});
		
		phoneEle.on("keyup", function() {
			if (dependency) {
				if ($(this).val() && $(dependency).val()) {
					self.enable();
				} else {
					self.disabled();
				}
			}
		});
	}
	
	function validatorAuthCode(dependency) {
		var authCode = this.$dialog.find("#security_account_verify_code");
		var self = this;
		ec.form.validator.bind(authCode, {
			type: ["require", "length", "numeric"],
			trim: false,
			min:4,
			max:8,
			validOnChange: true,
			msg_ct: "#auth_code_error_info",
			msg: {
				require: rss.inputAuthCodeTip,
				length: rss.authCodeLength,
				numeric: rss.authCodeLength
			}
		});
		
		this.disabled();
		
		authCode.on("keyup", function(e) {
			if ($(this).val()) {
				$("#auth_code_error_info").empty();
				if (dependency) {
					if ($(dependency).val()) {
						self.enable();
					}
				} else {
					self.enable();
				}
			} else {
				self.disabled();
			}
		});
	}
	
	function registerValidator() {
		//reg validate type pwdformat
		ec.form.validator.register("pwdformat", function(b_val, a) {
			if (a.allowEmpty && ec.util.isEmpty(b_val)) {
				return true;
			}
		});
		
		ec.form.validator.register("pwdComplax", function(b_val, a) {
			return true;
		});
		
		ec.form.validator.register("pwdEqual", function(b_val, a) {
			if (!a.compareTo.val()) {
				return true;
			} else {
				if (b_val == a.compareTo.val()) {
					return true;
				} else {
					return false;
				}
			}
		});
		
		ec.form.validator.register("phoneNumber", function(b_val, a) {
			var currentCountryCode = $("#security_phone_set_country_code > input").val();
			var reg = "";
			if (currentCountryCode && currentCountryCode == "0086") {
				reg = /^(1[34578])[0-9]{9}$|(^(\+|00)852[9865])[0-9]{7}$/;
			} else if(currentCountryCode == "001" || currentCountryCode == "+1"){
				reg = /^[0-9]{10}$/;
			} else {
				reg = /^[0-9]{5,15}$/;
			}
			return reg.test(b_val) ? true : false;
		});
	}
	
	function initString () {
		$(".account_column").text(rss.account);
	}
	
})(jQuery,window);